home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / textureWindowCreateToolBar.m < prev    next >
Encoding:
Text File  |  2003-07-17  |  29.8 KB  |  1,072 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Script:    textureWindowCreateToolBar.mel
  19. //
  20. //*AUTOMATIC: yes
  21. //
  22. //
  23. // SYNOPSIS
  24. //        Creates a toolbar for the panel that contains the texture window
  25. //
  26.  
  27. global proc int textureWindowCreateToolBar_isUVTransformed()
  28. //
  29. // Description:
  30. //    this procedure updates the fields if the UV is transformed or
  31. //    if a new UV is selected. If more than 1 UV is selected, the lowest 
  32. //    indexed UV's coordinates are displayed
  33.  
  34. {
  35.     int $return = 0;
  36.     string $UVs[] = `filterExpand -selectionMask 35`;
  37.     global float $gUVvalues[];
  38.     global float $gPreviousUVvalues[];
  39.  
  40.     //    is the texture editor visible?
  41.     int $texturePanelVisible = 0;
  42.     string $visiblePanels[] = `getPanel -visiblePanels`;
  43.     for ($panel in $visiblePanels){
  44.         if ($panel == "polyTexturePlacementPanel1") $texturePanelVisible = 1;
  45.     }
  46.  
  47.     if ($texturePanelVisible){
  48.         if ((size($UVs)) > 0){
  49.             $gUVvalues = `polyEditUV -query $UVs[0]`;
  50.  
  51.             if (!`size ($gPreviousUVvalues)`){
  52.                 $gPreviousUVvalues[0] = $gUVvalues[0];
  53.                 $gPreviousUVvalues[1] = $gUVvalues[1];
  54.             }
  55.             if ($gPreviousUVvalues[0] != $gUVvalues[0]){
  56.                 floatField -edit
  57.                     -value $gUVvalues[0]
  58.                     uvEntryFieldU;        
  59.                 $gPreviousUVvalues[0] = $gUVvalues[0];
  60.                 $return = 1;
  61.             }
  62.             if ($gPreviousUVvalues[1] != $gUVvalues[1]){
  63.                 floatField -edit
  64.                     -value $gUVvalues[1]
  65.                     uvEntryFieldV;        
  66.                 $gPreviousUVvalues[1] = $gUVvalues[1];
  67.                 $return = 1;
  68.             }
  69.         } else {
  70.             //    need to initiate values if they've not been set yet
  71.             $gUVvalues[0] = 0.0001; $gUVvalues[1] = 0.0001;
  72.             $gPreviousUVvalues[0] = 0.0002; $gPreviousUVvalues[1] = 0.0002;
  73.         }
  74.     }
  75.     return $return;
  76. }
  77.  
  78. global proc textureWindowCreateToolBar_uvCopy()
  79. //
  80. // Description:
  81. //    this procedure defines the copy behaviour for UV mode
  82. //
  83. {
  84.     global float $gUVcopyValues[];
  85.     $gUVcopyValues = `polyEditUV -q`;
  86. }
  87.  
  88. global proc textureWindowCreateToolBar_uvPaste( int $u, int $v)
  89. //
  90. // Description:
  91. //    this procedure defines the paste behaviour for UV mode
  92. //        $u: boolean - paste U value
  93. //        $v: boolean - paste V value
  94. //
  95. {
  96.     global float $gUVcopyValues[];
  97.     string $UVs[] = `ls -selection -flatten`;
  98.     for ($UV in $UVs){
  99.         if ($u == 1){
  100.             polyEditUV -r false -u $gUVcopyValues[0];
  101.         }
  102.         if ($v == 1){
  103.             polyEditUV -r false -v $gUVcopyValues[1];
  104.         }
  105.     }
  106. }
  107.  
  108.  
  109. global proc textureWindowCreateToolBar_copyPasteMode (int $mode)
  110. //
  111. // Description:
  112. //    this procedure updates the copy paste mode for the 
  113. //    toolbar
  114. //        0: off - copy faces
  115. //        1: on  - copy UVs
  116. //
  117. {
  118.     int $iconSize = 30;
  119.  
  120.     setUITemplate -pushTemplate TexWinButtonTemplate;
  121.  
  122.     switch ($mode){
  123.     case 0:
  124.         iconTextButton -edit
  125.             -command "PolygonCopy"
  126.             -annotation (getRunTimeCommandAnnotation ("PolygonCopy"))
  127.             copyUVButton;
  128.  
  129.         popupMenu -button 3
  130.             -parent copyUVButton
  131.             -postMenuCommand "PolygonCopyOptions"
  132.             copyUVButtonPopup;
  133.  
  134.         iconTextButton -edit
  135.             -command "PolygonPaste"
  136.             -annotation "Paste UVs to selected faces"
  137.             pasteUVButton;
  138.  
  139.         popupMenu -button 3
  140.             -parent pasteUVButton
  141.             -postMenuCommand "PolygonPasteOptions"
  142.             pasteUVButtonPopup;
  143.  
  144.         iconTextButton -edit 
  145.             -enable false 
  146.             //-image1 "pasteUDisabled.xpm"
  147.             pasteUButton;
  148.  
  149.         iconTextButton -edit 
  150.             -enable false 
  151.             //-image1 "pasteVDisabled.xpm"
  152.             pasteVButton;
  153.  
  154.         break;
  155.  
  156.     case 1:
  157.         //    adjust copy/paste buttons
  158.         iconTextButton -edit
  159.             -command "textureWindowCreateToolBar_uvCopy"
  160.             -annotation "Copy UV values of selected UV"
  161.             copyUVButton;
  162.  
  163.         iconTextButton -edit
  164.             -command "textureWindowCreateToolBar_uvPaste 1 1"
  165.             -annotation "Paste UV values to selected UVs"
  166.             pasteUVButton;
  167.  
  168.         //    delete their popup menus
  169.         deleteUI -menu copyUVButtonPopup;
  170.         deleteUI -menu pasteUVButtonPopup;
  171.  
  172.         //    enable paste U and V buttons
  173.         iconTextButton -edit 
  174.             -enable true 
  175.             //-image1 "pasteU.xpm"
  176.             pasteUButton;
  177.  
  178.         iconTextButton -edit 
  179.             -enable true 
  180.             //-image1 "pasteV.xpm"
  181.             pasteVButton;
  182.  
  183.         break;
  184.     }
  185.  
  186.     setUITemplate -popTemplate;
  187.  
  188. }
  189.  
  190.  
  191. global proc textureWindowCreateToolBar_toggleIcons ( int $arg, 
  192.                                                      string $iconLayout, 
  193.                                                      string $collapsedLayout, 
  194.                                                      string $shiftedLayout, 
  195.                                                      string $statusVariable )
  196. //
  197. // Description:
  198. //  Show and Hide the file icons
  199. // Parameters:
  200. //  $arg: 1 means show, 0 means hide, -1 means use optionVar
  201. //  $iconLayout: the name of the layout being toggled
  202. //  $collapsedLayout: the name of the layout/icon containing the open/close bar
  203. //  $shiftedLayout: The name of the layout neighboring iconLayout to the right.
  204. //                  This layout will be shifted over when iconLayout is hidden.
  205. //                    If no righthand layout exists, this parameter should be any
  206. //                    invalid layout name (ex: "").
  207. //  $statusVariable: the optionVar storing whether or not $iconLayout is hidden
  208. //                     or shown.
  209. //
  210. {    
  211.     // UV Texture Editor Toolbar (the parent of all icon layouts)
  212.     //
  213.     global string $gUVTexEditToolBar;
  214.     setParent $gUVTexEditToolBar;
  215.  
  216.     int $state = $arg;
  217.     if ($state < 0) $state = (!`optionVar -q $statusVariable`);
  218.  
  219.     // Determine whether or not the specified $shiftedLayout exists
  220.     //
  221.     int $doesShiftedExist = false;
  222.     string $children[] = `formLayout -q -childArray $gUVTexEditToolBar`;
  223.     int $i = 0;
  224.     for ($i = 0; $i < `formLayout -q -numberOfChildren $gUVTexEditToolBar`; $i++ ) {
  225.         if ($children[$i] == $shiftedLayout) {
  226.             $doesShiftedExist = true;
  227.             break;
  228.         }
  229.     }
  230.  
  231.     // number of pixels between neighboring layouts
  232.     //
  233.     int $edging = 2;
  234.     if ($state) {
  235.         // Show $iconLayout
  236.         //
  237.  
  238.         // Because the toolbar contains both gridLayouts and formLayouts,
  239.         // we need to check which one is being toggled
  240.         //
  241.         if ( `gridLayout -exists $iconLayout`) {
  242.             gridLayout -edit -manage true $iconLayout;
  243.         } else if ( `formLayout -exists $iconLayout` ) {
  244.             formLayout -edit -manage true $iconLayout;
  245.         }
  246.         
  247.         // Shift right hand neighbor back to the right
  248.         //
  249.         if ($doesShiftedExist) {
  250.             formLayout -e 
  251.                 -ac $shiftedLayout left $edging $iconLayout 
  252.                 $gUVTexEditToolBar;
  253.         }
  254.  
  255.         iconTextButton -edit -i1 textureEditorOpenBar.xpm $collapsedLayout;
  256.     } else {
  257.         // Hide $iconLayout
  258.         //
  259.  
  260.         // Because the toolbar contains both gridLayouts and formLayouts,
  261.         // we need to check which one is being toggled
  262.         //
  263.         if ( `gridLayout -exists $iconLayout`) {
  264.             gridLayout -edit -manage false $iconLayout;
  265.         } else if ( `formLayout -exists $iconLayout` ) {
  266.             formLayout -edit -manage false $iconLayout;
  267.         }
  268.  
  269.         // Shift right hand neighbor over to the left
  270.         //
  271.         if ($doesShiftedExist) {
  272.             formLayout -e 
  273.                 -ac $shiftedLayout left $edging $collapsedLayout 
  274.                 $gUVTexEditToolBar;
  275.         }
  276.  
  277.         iconTextButton -edit -i1 textureEditorCloseBar.xpm $collapsedLayout;
  278.     }
  279.  
  280.     // the status variable should now represent the current state
  281.     // (shown: 1, hidden: 0)
  282.     //
  283.     optionVar -intValue $statusVariable $state;
  284. }
  285.  
  286. global proc textureWindowCreateToolBar(string $toolBar,
  287.                                        string $editor,
  288.                                        string $editorCmd)
  289. //
  290. // Description:
  291. //    Add the texture window toolbar
  292. //
  293. //  A call to txtWndUpdateEditor has been added to several of the
  294. //    buttons. This is to keep those buttons (which toggle between two
  295. //    states) and the equivalent menuItems in sync.
  296. // 
  297. // Returns: name of toolbar widget
  298. //
  299. {
  300.     // So the icon toggle procedures know who their parent is
  301.     global string $gUVTexEditToolBar;
  302.     $gUVTexEditToolBar = $toolBar;
  303.     
  304.     // Space between icons
  305.     int $vertGap = 5;
  306.     int $horizGap = 2;
  307.  
  308.     // Add in the icons
  309.     int $iconSize = 30;
  310.     int $floatWidth = 30;
  311.  
  312.     // Open/Close bar size
  313.     int $barHeight = 2 * $iconSize + $vertGap;
  314.     int $barWidth = 9;
  315.  
  316.     // Template for the quick collapse bar, and the hide/show bars
  317.     //
  318.     if (`uiTemplate -exists TexWinBarTemplate`) {
  319.         deleteUI -uiTemplate TexWinBarTemplate;
  320.     }
  321.     uiTemplate TexWinBarTemplate;
  322.     iconTextButton -defineTemplate TexWinBarTemplate
  323.         -width $barWidth -height $barHeight;
  324.  
  325.     // Template for all the toolbar push buttons
  326.     // 
  327.     if (`uiTemplate -exists TexWinButtonTemplate`) {
  328.         deleteUI -uiTemplate TexWinButtonTemplate;
  329.     }
  330.     uiTemplate TexWinButtonTemplate;
  331.     iconTextButton -defineTemplate TexWinButtonTemplate
  332.         -width $iconSize -height $iconSize;
  333.  
  334.     // Template for all the toolbar toggle buttons
  335.     //
  336.     if (`uiTemplate -exists TexWinCheckBoxTemplate`) {
  337.         deleteUI -uiTemplate TexWinCheckBoxTemplate;
  338.     }
  339.     uiTemplate TexWinCheckBoxTemplate;
  340.     iconTextCheckBox -defineTemplate TexWinCheckBoxTemplate
  341.         -width $iconSize -height $iconSize;
  342.  
  343.     // Template for the toolbar float fields
  344.     //
  345.     if (`uiTemplate -exists TexWinFloatFieldTemplate`) {
  346.         deleteUI -uiTemplate TexWinFloatFieldTemplate;
  347.     }
  348.     uiTemplate TexWinFloatFieldTemplate;
  349.     iconTextCheckBox -defineTemplate TexWinFloatFieldTemplate
  350.         -width $floatWidth -height $iconSize;
  351.     
  352.     //////////////////
  353.     //     Flip/Rotate //
  354.     //////////////////
  355.         
  356.     
  357.     // 
  358.     // Init hidden/shown option var
  359.     //
  360.     if (!`optionVar -exists "showStatusFlipRotate"`) {
  361.         optionVar -intValue "showStatusFlipRotate" 1;
  362.     }
  363.  
  364.     //
  365.     // Set up open/close bar
  366.     //
  367.     setUITemplate -pushTemplate TexWinBarTemplate;
  368.  
  369.     iconTextButton -vis true
  370.         -parent $gUVTexEditToolBar
  371.         -ann "Show/hide the flip/rotate icons"
  372.         -i1 textureEditorOpenBar.xpm  
  373.         -c ("textureWindowCreateToolBar_toggleIcons(-1," +
  374.             "\"flipRotateLayout\", " +
  375.             "\"flipRotateCollapse\", " + 
  376.             "\"moveSewCollapse\", " + 
  377.             "\"showStatusFlipRotate\")")
  378.         flipRotateCollapse;
  379.  
  380.     setUITemplate -popTemplate;
  381.  
  382.     //
  383.     // Set up icons
  384.     //
  385.     formLayout flipRotateLayout;
  386.  
  387.     setUITemplate -pushTemplate TexWinButtonTemplate;
  388.  
  389.     iconTextButton
  390.         -image1 "flipU.xpm"
  391.         //    note polyForceUVs may be phased out - it's marked obsolete
  392.         //    but it converts the selection and doesn't mess up tri-strips
  393.         //    like polyFlipUV (if you change, don't forget flipV below)
  394.         //-command "ConvertSelectionToFaces; polyFlipUV -flipType 0 -local on"
  395.         -command "polyForceUV -flipHorizontal -local"
  396.         -annotation "Flip UVs: Flip selected UVs in U direction"
  397.         flipUButton;
  398.  
  399.     iconTextButton
  400.         -image1 "flipV.xpm"
  401.         //-command "ConvertSelectionToFaces; polyFlipUV -flipType 1 -local on"
  402.         -command "polyForceUV -flipVertical -local"
  403.         -annotation "Flip UVs: Flip selected UVs in V direction"
  404.         flipVButton;
  405.  
  406.     iconTextButton
  407.         -image1 "rotateUVcw.xpm"
  408.         -command ("string $selection[] = `ls -sl`;" +
  409.                   "ConvertSelectionToUVs; polyRotateUVs -45;" +
  410.                   "select -replace $selection")
  411.         -annotation "Rotate UVs: Rotate selected UVs clockwise"
  412.         rotateCWButton;
  413.  
  414.     iconTextButton
  415.         -image1 "rotateUVccw.xpm"
  416.         -command ("string $selection[] = `ls -sl`;" +
  417.                   "ConvertSelectionToUVs; polyRotateUVs 45;" +
  418.                   "select -replace $selection")
  419.         -annotation "Rotate UVs: Rotate selected UVs counter clockwise"
  420.         rotateCCWButton;
  421.  
  422.     setUITemplate -popTemplate;
  423.  
  424.     //
  425.     // Position icons
  426.     //
  427.     formLayout -edit
  428.         -attachForm     flipUButton            "top"   0
  429.         -attachForm     flipUButton            "left"  0
  430.  
  431.         -attachControl  flipVButton            "left"    2 flipUButton
  432.         -attachForm     flipVButton            "top"    0
  433.  
  434.         -attachForm     rotateCCWButton        "left"  0
  435.         -attachControl  rotateCCWButton        "top"    2 flipUButton
  436.         -attachControl  rotateCWButton        "left"  2 rotateCCWButton
  437.         -attachControl  rotateCWButton        "top"    2 flipVButton
  438.  
  439.         flipRotateLayout;
  440.  
  441.     //////////////
  442.     // Move/Sew //
  443.     //////////////
  444.  
  445.  
  446.     setParent ..;
  447.  
  448.     //
  449.     // Init hidden/shown option var
  450.     //
  451.     if (!`optionVar -exists "showStatusMoveSew"`) {
  452.         optionVar -intValue "showStatusMoveSew" 1;
  453.     }
  454.  
  455.     //
  456.     // Set up open/close bar
  457.     //
  458.     setUITemplate -pushTemplate TexWinBarTemplate;
  459.  
  460.     iconTextButton -vis true
  461.         -parent $gUVTexEditToolBar
  462.         -ann "Show/hide the move/sew icons"
  463.         -i1 textureEditorOpenBar.xpm  
  464.         -c ("textureWindowCreateToolBar_toggleIcons(-1, " + 
  465.             "\"moveSewLayout\", " + 
  466.             "\"moveSewCollapse\", " + 
  467.             "\"alignCollapse\", " + 
  468.             "\"showStatusMoveSew\")")
  469.         moveSewCollapse;
  470.  
  471.     setUITemplate -popTemplate;
  472.  
  473.     //
  474.     // Set up icons
  475.     //
  476.     gridLayout -numberOfRowsColumns 2 3 moveSewLayout;
  477.  
  478.     setUITemplate -pushTemplate TexWinButtonTemplate;
  479.  
  480.     iconTextButton
  481.         -image1 "cutUV.xpm"
  482.         -command "polyMapCut"
  483.         -annotation "Cut UVs: Separate the UVs along the selected edges"
  484.         cutButton;
  485.  
  486.     iconTextButton
  487.         -image1 "sewUV.xpm"
  488.         // merge UVs if not edges
  489.         -command ("string $edges[] = `filterExpand -selectionMask 32`;" +
  490.             "string $uvs[] = `filterExpand -selectionMask 35`;" +
  491.             "if (size($edges) > 0) polyMapSew;" +
  492.             "if (size($uvs) > 0) performPolyMergeUV 0;")
  493.         -annotation "Sew UVs: Sew the selected edges or UVs together"
  494.         sewButton;
  495.  
  496.     popupMenu -button 3
  497.         -parent sewButton
  498.         -postMenuCommand "performPolyMergeUV 1"
  499.         sewButtonPopup;
  500.  
  501.     iconTextButton
  502.         -image1 "layoutUV.xpm"
  503.         -command "ConvertSelectionToFaces; performPolyLayoutUV 0"
  504.         -annotation "Layout UVs: Select faces to be moved in UV space"
  505.         layoutButton;
  506.  
  507.     popupMenu -button 3
  508.         -parent layoutButton
  509.         -postMenuCommand "performPolyLayoutUV 1"
  510.         layoutButtonPopup;
  511.  
  512.     iconTextButton
  513.         -image1 "moveSewUV.xpm"
  514.         -command "performPolyMapSewMove 0"
  515.         -annotation "Move and Sew UVs: Move and sew the the selected edges"
  516.         moveSewButton;
  517.  
  518.     popupMenu -button 3
  519.         -parent moveSewButton
  520.         -postMenuCommand "performPolyMapSewMove 1"
  521.         moveSewButtonPopup;
  522.  
  523.     iconTextButton 
  524.         -image1 "splitUV.xpm" 
  525.         -annotation "Split Selected UV: Separate the selected UV into one for each connected edge"
  526.         -command "polySplitTextureUV"
  527.         splitUVButton;
  528.  
  529.     iconTextButton
  530.             -image1 "cycleUVs.xpm"
  531.             -command "polyRotateUVsByVertex"
  532.             -annotation "Cycle UVs: Cycles the UVs of the selected face counter clockwise."
  533.             cycleUVsButton;
  534.  
  535.     setUITemplate -popTemplate;
  536.  
  537.  
  538.     ///////////
  539.     // Align //
  540.     ///////////
  541.     setParent ..;
  542.  
  543.  
  544.     //
  545.     // Init hidden/shown option var
  546.     //
  547.     if (!`optionVar -exists "showStatusAlign"`) {
  548.         optionVar -intValue "showStatusAlign" 1;
  549.     }
  550.  
  551.     //
  552.     // Set up open/close bar
  553.     //
  554.     setUITemplate -pushTemplate TexWinBarTemplate;
  555.  
  556.     iconTextButton -vis true
  557.         -parent $gUVTexEditToolBar
  558.         -ann "Show/hide the flip/rotate icons"
  559.         -i1 textureEditorOpenBar.xpm  
  560.         -c ("textureWindowCreateToolBar_toggleIcons(-1," +
  561.             "\"alignLayout\", " + 
  562.             "\"alignCollapse\", " + 
  563.             "\"isolateSelectCollapse\", " + 
  564.             "\"showStatusAlign\")")
  565.         alignCollapse;
  566.  
  567.     setUITemplate -popTemplate;
  568.  
  569.     //
  570.     // Set up icons
  571.     //
  572.     gridLayout -numberOfRowsColumns 2 3 alignLayout;
  573.  
  574.     setUITemplate -pushTemplate TexWinButtonTemplate;
  575.  
  576.     // align tools
  577.     iconTextButton
  578.         -image1 "alignUMin.xpm"
  579.         -command "alignUV 1 1 0 0"
  580.         -annotation "Align UVs: Align selected UVs to minimum U value"
  581.         alignUMinButton;
  582.  
  583.     iconTextButton
  584.         -image1 "alignUMax.xpm"
  585.         -command "alignUV 1 0 0 0"
  586.         -annotation "Align UVs: Align selected UVs to maximum U value"
  587.         alignUMaxButton;
  588.         
  589.     iconTextButton
  590.         -image1 "alignVMin.xpm"
  591.         -command "alignUV 0 0 1 1"
  592.         -annotation "Align UVs: Align selected UVs to minimum V value"
  593.         alignVMinButton;
  594.         
  595.     iconTextButton
  596.         -image1 "alignVMax.xpm"
  597.         -command "alignUV 0 0 1 0"
  598.         -annotation "Align UVs: Align selected UVs to maximum V value"
  599.         alignVMaxButton;
  600.  
  601.     iconTextButton
  602.         -image1 "polyGridUV.xpm"
  603.         -command "GridUV"
  604.         -annotation "Grid UVs: Snap selected UVs to user specified grid"
  605.         gridUVButton;
  606.  
  607.     popupMenu -button 3
  608.         -parent gridUVButton
  609.         -postMenuCommand "GridUVOptions"
  610.         gridUVPopup;
  611.  
  612.     iconTextButton
  613.         -image1 "relaxUV.xpm"
  614.         -command "performPolyUntangleUV relax 0"
  615.         -annotation "Relax UVs: Automatically move UVs for better texture space distribution"
  616.         relaxButton;
  617.  
  618.     popupMenu -button 3
  619.         -parent relaxButton
  620.         -postMenuCommand "performPolyUntangleUV relax 1"
  621.         relaxButtonPopup;
  622.     
  623.     setUITemplate -popTemplate;
  624.  
  625.     ////////////////////
  626.     // Isolate/Select //
  627.     ////////////////////
  628.  
  629.     setParent ..;
  630.  
  631.     //
  632.     // Init hidden/shown option var
  633.     //
  634.     if (!`optionVar -exists "showStatusIsolateSelect"`) {
  635.         optionVar -intValue "showStatusIsolateSelect" 1;
  636.     }
  637.  
  638.     //
  639.     // Set up open/close bar
  640.     //
  641.     setUITemplate -pushTemplate TexWinBarTemplate;
  642.  
  643.     iconTextButton -vis true
  644.         -parent $gUVTexEditToolBar
  645.         -ann "Show/hide the isolate/select icons"
  646.         -i1 textureEditorOpenBar.xpm  
  647.         -c ("textureWindowCreateToolBar_toggleIcons(-1," + 
  648.             "\"isolateSelectLayout\", " + 
  649.             "\"isolateSelectCollapse\", " + 
  650.             "\"displayCollapse\", " + 
  651.             "\"showStatusIsolateSelect\")")
  652.         isolateSelectCollapse;
  653.  
  654.     setUITemplate -popTemplate;
  655.  
  656.     //
  657.     // Set up icons
  658.     //
  659.     formLayout isolateSelectLayout;
  660.  
  661.     setUITemplate -pushTemplate TexWinCheckBoxTemplate;
  662.  
  663.     iconTextCheckBox 
  664.             -image1 "uvIsolateSelect.xpm" 
  665.             -onCommand("textureWindow -e -useFaceGroup 1 " + $editor + "; " +
  666.                        "optionVar -iv textureWindowShaderFacesMode 2;" +
  667.                        "txtWndUpdateEditor(" +
  668.                        "\"" + $editor + "\", " +
  669.                        "\"" + $editorCmd + "\", \"null\", 101);")
  670.             -offCommand ("textureWindow -e -useFaceGroup 0 " + $editor + "; " +
  671.                          "optionVar -iv textureWindowShaderFacesMode 0;" +
  672.                          "txtWndUpdateEditor(" + 
  673.                          "\"" + $editor + "\", " +
  674.                          "\"" + $editorCmd + "\", \"null\", 101);")
  675.             -annotation "Toggle Isolate Select mode"
  676.             -value `optionVar -q textureWindowShaderFacesMode`                
  677.             isolateSelectButton;
  678.  
  679.     setUITemplate -popTemplate;
  680.  
  681.     setUITemplate -pushTemplate TexWinButtonTemplate;
  682.  
  683.     iconTextButton
  684.             -image1 "uvIsolateSelectReset.xpm"
  685.             -command "textureEditorIsolateSelect 0;"
  686.             -annotation "Remove All: Remove all UVs of the selected object from the isolate select set."
  687.             isolateResetButton;
  688.  
  689.     iconTextButton
  690.             -image1 "uvIsolateSelectAdd.xpm"
  691.             -command "textureEditorIsolateSelect 1;"
  692.             -annotation "Add Selected: Add selected UVs to the isolate select set."
  693.             uvIsolateAddButton;
  694.  
  695.     iconTextButton
  696.             -image1 "uvIsolateSelectRemove.xpm"
  697.             -command "textureEditorIsolateSelect 2;"
  698.             -annotation "Remove Selected: Remove selected UVs to the isolate select set."
  699.             uvIsolateRemoveButton;
  700.  
  701.     setUITemplate -popTemplate;
  702.  
  703.     formLayout -edit
  704.         -attachForm     isolateSelectButton        "top"   0
  705.         -attachForm        isolateSelectButton        "left"  0 
  706.         -attachControl  uvIsolateAddButton        "left"    2 isolateSelectButton
  707.         -attachForm     uvIsolateAddButton        "top"    0
  708.  
  709.         -attachForm        isolateResetButton        "left"    0 
  710.         -attachControl    isolateResetButton        "top"    2 isolateSelectButton
  711.         -attachControl    uvIsolateRemoveButton    "left"    2 isolateResetButton
  712.         -attachControl    uvIsolateRemoveButton    "top"    2 uvIsolateAddButton
  713.         isolateSelectLayout;
  714.  
  715.     /////////////
  716.     // Display //
  717.     /////////////
  718.  
  719.     setParent ..;
  720.     // Display options
  721.  
  722.     //
  723.     // Init hidden/shown option var
  724.     // 
  725.     if (!`optionVar -exists "showStatusDisplay"`) {
  726.         optionVar -intValue "showStatusDisplay" 1;
  727.     }
  728.  
  729.     //
  730.     // Set up open/close bar
  731.     //
  732.     setUITemplate -pushTemplate TexWinBarTemplate;
  733.  
  734.     iconTextButton -vis true
  735.         -parent $gUVTexEditToolBar
  736.         -ann "Show/hide the display icons"
  737.         -i1 textureEditorOpenBar.xpm  
  738.         -c ("textureWindowCreateToolBar_toggleIcons(-1," +
  739.             "\"displayLayout\", " + 
  740.             "\"displayCollapse\", " + 
  741.             "\"copyPasteCollapse\", " + 
  742.             "\"showStatusDisplay\")")
  743.         displayCollapse;
  744.  
  745.     setUITemplate -popTemplate;
  746.  
  747.     //
  748.     // Set up icons
  749.     //
  750.     gridLayout -numberOfRowsColumns 2 4 displayLayout;
  751.  
  752.     setUITemplate -pushTemplate TexWinCheckBoxTemplate;
  753.  
  754.     iconTextCheckBox 
  755.         -image1 "imageDisplay.xpm" 
  756.         -onCommand("textureWindow -e -imageDisplay 1 " + $editor + "; " +
  757.                    "refresh; " +
  758.                    "txtWndUpdateEditor(" +
  759.                    "\"" + $editor + "\"," + 
  760.                    "\"" + $editorCmd + "\", \"null\", 101);")
  761.         -offCommand ("textureWindow -e -imageDisplay 0 " + $editor + "; " +
  762.                      "refresh; " +
  763.                      "txtWndUpdateEditor(" +
  764.                      "\"" + $editor + "\"," + 
  765.                      "\"" + $editorCmd + "\", \"null\", 101);")
  766.         -annotation "Show background image on/off"
  767.         -value `textureWindow -q -imageDisplay  $editor`
  768.         imageDisplayButton;
  769.  
  770.     popupMenu -button 3
  771.         -parent imageDisplayButton
  772.         -postMenuCommand "performTextureViewImageRangeOptions 1"
  773.         imageDisplayButtonPopup;
  774.         
  775.     iconTextCheckBox 
  776.         -image1 "gridDisplay.xpm" 
  777.         -onCommand ("textureWindow -e -toggle 1 " + $editor + "; " +
  778.                     "txtWndUpdateEditor(" +
  779.                     "\"" + $editor + "\"," + 
  780.                     "\"" + $editorCmd + "\", \"null\", 101);")
  781.         -offCommand ( "textureWindow -e -toggle 0 " + $editor + "; " +
  782.                       "txtWndUpdateEditor(" +
  783.                       "\"" + $editor + "\"," + 
  784.                       "\"" + $editorCmd + "\", \"null\", 101);")
  785.         -annotation "Show grid on/off"
  786.         -value `textureWindow -q -toggle $editor`
  787.         gridDisplayButton;
  788.  
  789.     popupMenu -button 3
  790.         -parent gridDisplayButton
  791.         -postMenuCommand "performTextureViewGridOptions 1"
  792.         gridDisplayButtonPopup;
  793.  
  794.     iconTextCheckBox 
  795.         -image1 "pixelSnap.xpm" 
  796.         -onCommand ("textureWindow -e -imagePixelSnap 1 " + $editor + "; " +
  797.                     "txtWndUpdateEditor(" +
  798.                     "\"" + $editor + "\"," + 
  799.                     "\"" + $editorCmd + "\", \"null\", 101);")
  800.         -offCommand ("textureWindow -e -imagePixelSnap 0 " + $editor + "; " +
  801.                      "txtWndUpdateEditor(" +
  802.                      "\"" + $editor + "\"," + 
  803.                      "\"" + $editorCmd + "\", \"null\", 101);")
  804.         -annotation "Toggle snap to pixels on/off"
  805.         -value `textureWindow -q -imagePixelSnap $editor`
  806.         pixelSnapButton;
  807.  
  808.     iconTextCheckBox 
  809.         -image1 "filteredMode.xpm" 
  810.         -onCommand ("textureWindow -e -imageUnfiltered 1 " + $editor + "; " +
  811.                     "txtWndUpdateEditor(" +
  812.                     "\"" + $editor + "\"," + 
  813.                     "\"" + $editorCmd + "\", \"null\", 101);")
  814.         -offCommand ( "textureWindow -e -imageUnfiltered 0 " + $editor + "; " +
  815.                       "txtWndUpdateEditor(" +
  816.                       "\"" + $editor + "\"," + 
  817.                       "\"" + $editorCmd + "\", \"null\", 101);")
  818.         -annotation "Toggle filtered display mode on/off"
  819.         -value `textureWindow -q -imageUnfiltered $editor`
  820.         filteredButton;
  821.  
  822.     iconTextCheckBox 
  823.         -image1 "imageRatio.xpm" 
  824.         -onCommand ("textureWindow -e -imageRatio 1 " + $editor + "; " +
  825.                     "txtWndUpdateEditor(" +
  826.                     "\"" + $editor + "\"," + 
  827.                     "\"" + $editorCmd + "\", \"null\", 101);")
  828.         -offCommand ( "textureWindow -e -imageRatio 0 " + $editor + "; " +
  829.                       "txtWndUpdateEditor(" +
  830.                       "\"" + $editor + "\"," + 
  831.                       "\"" + $editorCmd + "\", \"null\", 101);")
  832.         -annotation "Toggle image ratio on/off"
  833.         -value `textureWindow -q -imageRatio $editor`
  834.         ratioButton;
  835.  
  836.     setUITemplate -popTemplate;
  837.  
  838.     setUITemplate -pushTemplate TexWinButtonTemplate;
  839.  
  840.     iconTextButton
  841.         -image1 "textureBorder.xpm"
  842.         -command ("int $borders[] = `polyOptions -q -displayMapBorder`;" +
  843.                   "float $borderWidth[] = `optionVar -q displayPolyBorderEdgeSize`;" +
  844.                   "polyOptions -displayMapBorder (!$borders[0]) -sizeBorder $borderWidth[1]")
  845.         -annotation "Toggle Texture Borders: Toggle the display of texture borders for the active mesh"
  846.         polyDisplayButton;
  847.  
  848.     popupMenu -button 3
  849.         -parent polyDisplayButton
  850.         -postMenuCommand "CustomPolygonDisplayOptions"
  851.         polyDisplayPopup;
  852.  
  853.     iconTextButton
  854.         -image1 "rvAllPlanes.xpm"
  855.         -annotation "Display RGB Channels"
  856.         -command
  857.         ("textureWindow -e -displayStyle \"color\" " + $editor)
  858.         colorButton;
  859.  
  860.     iconTextButton
  861.         -image1 "rvMaskPlane.xpm"
  862.         -annotation "Display Alpha Channel"
  863.         -command                 
  864.         ("textureWindow -e -displayStyle \"mask\" " + $editor)
  865.         maskButton;    
  866.  
  867.     setUITemplate -popTemplate;
  868.  
  869.     ////////////////
  870.     // Copy/Paste //
  871.     ////////////////
  872.     setParent ..;
  873.  
  874.     //
  875.     // Init hidden/shown option var
  876.     //
  877.     if (!`optionVar -exists "showStatusCopyPaste"`) {
  878.         optionVar -intValue "showStatusCopyPaste" 1;
  879.     }
  880.  
  881.     //
  882.     // Set up open/close bar
  883.     //
  884.     setUITemplate -pushTemplate TexWinBarTemplate;
  885.  
  886.     iconTextButton -vis true
  887.         -parent $gUVTexEditToolBar
  888.         -ann "Show/hide the copy/paste icons"
  889.         -i1 textureEditorOpenBar.xpm  
  890.         -c ("textureWindowCreateToolBar_toggleIcons(-1," +
  891.             "\"copyPasteLayout\", " +
  892.             "\"copyPasteCollapse\", " +
  893.             "\"\", " + 
  894.             "\"showStatusCopyPaste\")")
  895.         copyPasteCollapse;
  896.  
  897.     setUITemplate -popTemplate;
  898.  
  899.     //
  900.     // Set up icons
  901.     //
  902.     // copy/paste controls
  903.     formLayout copyPasteLayout;
  904.  
  905.     // UV Entry field. Will allow user to set current uv value
  906.     // of uv in selection list. Will update when selection list
  907.     // changes. 
  908.     //
  909.     // Ideally the fields should update as the selected UV(s)
  910.     // is/are transformed but there is not a good way to do
  911.     // this. Should be an event that exists for scriptJob.
  912.  
  913.     setUITemplate -pushTemplate TexWinFloatFieldTemplate;
  914.  
  915.     floatField 
  916.         -precision 3
  917.         -ed true
  918.         -enterCommand "polyEditUV -r false -u `floatField -q -value uvEntryFieldU`"
  919.         -cc "polyEditUV -r false -u `floatField -q -value uvEntryFieldU`"
  920.         -ann "Enter value to set U value to"
  921.         uvEntryFieldU;
  922.  
  923.     floatField 
  924.         -precision 3
  925.         -ed true
  926.         -enterCommand "polyEditUV -r false -v `floatField -q -value uvEntryFieldV`"
  927.         -cc "polyEditUV -r false -v `floatField -q -value uvEntryFieldV`"
  928.         -ann "Enter value to set V value to"
  929.         uvEntryFieldV;
  930.  
  931.     setUITemplate -popTemplate;
  932.  
  933.     setUITemplate -pushTemplate TexWinButtonTemplate;
  934.  
  935.     // originally planned to lock current UV values but it's
  936.     // more important to have an update button for the selected
  937.     // UV's coordinates
  938.     iconTextButton 
  939.         -image1 "uvUpdate.xpm" 
  940.         -annotation "Refresh the current UV values"
  941.         -command "textureWindowCreateToolBar_isUVTransformed"
  942.         updateValueButton;
  943.  
  944.     iconTextButton
  945.         -image1 "copyUV.xpm"
  946.         -command "PolygonCopy"
  947.         -annotation (getRunTimeCommandAnnotation ("PolygonCopy"))
  948.         copyUVButton;
  949.  
  950.     popupMenu -button 3
  951.         -parent copyUVButton
  952.         -postMenuCommand "PolygonCopyOptions"
  953.         copyUVButtonPopup;
  954.  
  955.     iconTextButton
  956.         -image1 "pasteUV.xpm"
  957.         -command "PolygonPaste"
  958.         -annotation (getRunTimeCommandAnnotation ("PolygonPaste"))
  959.         pasteUVButton;
  960.  
  961.     popupMenu -button 3
  962.         -parent pasteUVButton
  963.         -postMenuCommand "PolygonPasteOptions"
  964.         pasteUVButtonPopup;
  965.  
  966.     setUITemplate -popTemplate;
  967.  
  968.     setUITemplate -pushTemplate TexWinCheckBoxTemplate;
  969.  
  970.     iconTextCheckBox 
  971.         -image1 "copyUVMode.xpm" 
  972.         -onCommand        "textureWindowCreateToolBar_copyPasteMode 1"
  973.         -offCommand        "textureWindowCreateToolBar_copyPasteMode 0"
  974.         -annotation "Toggle copy/paste for faces/UVs"
  975.         copyModeButton;
  976.  
  977.     setUITemplate -popTemplate;
  978.  
  979.     setUITemplate -pushTemplate TexWinButtonTemplate;
  980.  
  981.     iconTextButton
  982.         -enable false
  983.         -image1 "pasteU.xpm"
  984.         -command "textureWindowCreateToolBar_uvPaste 1 0"
  985.         -annotation "Paste U value to selected UVs"
  986.         pasteUButton;
  987.  
  988.     iconTextButton
  989.         -enable false
  990.         -image1 "pasteV.xpm"
  991.         -width $iconSize -height $iconSize
  992.         -command "textureWindowCreateToolBar_uvPaste 0 1"
  993.         -annotation "Paste V value to selected UVs"
  994.         pasteVButton;
  995.  
  996.     setUITemplate -popTemplate;
  997.  
  998.     formLayout -edit
  999.     
  1000.         -attachForm     uvEntryFieldU        "top"    $vertGap
  1001.         -attachForm        uvEntryFieldU        "left"    0 
  1002.         -attachForm     uvEntryFieldV        "top"    $vertGap
  1003.         -attachControl  uvEntryFieldV        "left"    $horizGap uvEntryFieldU
  1004.         -attachForm     updateValueButton    "top"    0
  1005.         -attachControl  updateValueButton    "left"    $horizGap uvEntryFieldV
  1006.  
  1007.         -attachControl    copyUVButton        "top"    $vertGap uvEntryFieldU
  1008.         -attachForm        copyUVButton        "left"    0
  1009.         -attachControl  pasteUVButton        "top"    $vertGap uvEntryFieldU
  1010.         -attachControl  pasteUVButton        "left"    $horizGap copyUVButton
  1011.         -attachControl  pasteUButton        "top"    $vertGap uvEntryFieldU
  1012.         -attachControl  pasteUButton        "left"    $horizGap pasteUVButton
  1013.         -attachControl  pasteVButton        "top"    $vertGap uvEntryFieldU
  1014.         -attachControl  pasteVButton        "left"    $horizGap pasteUButton
  1015.         -attachControl  copyModeButton        "top"    $vertGap uvEntryFieldU
  1016.         -attachControl  copyModeButton        "left"    $horizGap pasteVButton
  1017.         copyPasteLayout;        
  1018.  
  1019.     ///////////////////////////////
  1020.     // UV Texture Editor ToolBar //
  1021.     ///////////////////////////////
  1022.  
  1023.     setParent ..;
  1024.  
  1025.  
  1026.     // build form
  1027.     formLayout -edit  
  1028.  
  1029.         -attachForm        flipRotateCollapse    "top"    $vertGap
  1030.         -attachForm        flipRotateCollapse    "left"    0
  1031.  
  1032.         -attachForm     flipRotateLayout    "top"   $vertGap
  1033.         -attachControl    flipRotateLayout    "left"  2 flipRotateCollapse
  1034.  
  1035.         -attachForm     moveSewCollapse        "top"   $vertGap
  1036.         -attachControl    moveSewCollapse        "left"  2 flipRotateLayout
  1037.  
  1038.         -attachForm     moveSewLayout        "top"   $vertGap
  1039.         -attachControl    moveSewLayout        "left"    2 moveSewCollapse
  1040.  
  1041.         -attachForm     alignCollapse        "top"   $vertGap
  1042.         -attachControl    alignCollapse        "left"    2 moveSewLayout
  1043.  
  1044.         -attachForm     alignLayout            "top"   $vertGap
  1045.         -attachControl    alignLayout            "left"    2 alignCollapse
  1046.  
  1047.         -attachForm     isolateSelectCollapse        "top"   $vertGap
  1048.         -attachControl    isolateSelectCollapse        "left"    2 alignLayout
  1049.  
  1050.         -attachForm     isolateSelectLayout        "top"   $vertGap
  1051.         -attachControl    isolateSelectLayout        "left"    2 isolateSelectCollapse
  1052.  
  1053.         -attachForm     displayCollapse        "top"   $vertGap
  1054.         -attachControl    displayCollapse        "left"    2 isolateSelectLayout
  1055.  
  1056.         -attachForm     displayLayout        "top"   $vertGap
  1057.         -attachControl    displayLayout        "left"    2 displayCollapse
  1058.  
  1059.         -attachForm     copyPasteCollapse    "top"   $vertGap
  1060.         -attachControl    copyPasteCollapse    "left"    2 displayLayout
  1061.  
  1062.         -attachForm     copyPasteLayout        "top"   $vertGap
  1063.         -attachControl    copyPasteLayout        "left"    2 copyPasteCollapse
  1064.     
  1065.         $toolBar;
  1066.  
  1067.     // scriptJob to update the UV fields
  1068.     scriptJob -parent $editor
  1069.         -event "SelectionChanged"
  1070.         "textureWindowCreateToolBar_isUVTransformed";
  1071. }
  1072.